<?php
/**
 * Created by PhpStorm.
 * User: qinlu
 * Date: 2018/10/1
 * Time: 下午5:48
 * 定时任务 - 每天00：00：00删除看广告赚钱的记录
 */

namespace Core\Controller;
use Think\Controller;

class DeleteDataController extends Controller
{
    public function index()
    {
        set_time_limit(0);
        $time = strtotime(date('Y-m-d', time()));//当天00：00：00
        $where['create_time'] = ['lt',$time];
        $look = M('user_surf_ad_log')->where($where)->save(array('is_valid'=>0));//看广告记录表
        $answer = M('user_answer_ad_log')->where($where)->save(array('is_valid'=>0));//回答问题记录表
        $share = M('user_share_ad_log')->where($where)->save(array('is_valid'=>0));//分享记录表
        $res = [
            "answer" => $answer,
            "share" => $share,
            "look" => $look,
        ];
        echo json_encode( $res );
    }
}
